//package org.example.controller.douban;
//
//import org.example.entity.Item;
//import org.example.service.ItemService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import us.codecraft.webmagic.ResultItems;
//import us.codecraft.webmagic.Task;
//import us.codecraft.webmagic.pipeline.Pipeline;
//
//import javax.transaction.Transactional;
//import java.util.List;
//
////数据持久化
//@Component
//public class DouBanPipeline implements Pipeline {
//    @Autowired
//    private ItemService itemService;
//    @Override
//    public void process(ResultItems resultItems, Task task) {
//        List<Item>itemList=resultItems.get("itemList");
//        if (itemList!=null){
//            for (Item item : itemList) {
//                itemService.save(item);
//            }
//        }
//        Item item=resultItems.get("item");
//        if (item!=null){
//           Item item1= itemService.lambdaQuery().eq(Item::getNovelId,item.getNovelId()).one();
//           item1.setLatelyUpdateTime(item.getLatelyUpdateTime());
//           itemService.updateById(item1);
//        }
//    }
//}
